package com.lindroid.materialdesigndemo.bottomsheetdemo;

import android.os.Bundle;
import android.support.design.widget.BottomSheetBehavior;
import android.support.design.widget.BottomSheetDialog;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.LinearLayout;

import com.lindroid.materialdesigndemo.R;

import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * @author linyulong
 */
public class BottomSheetDialogActivity extends AppCompatActivity {
    private BottomSheetDialog dialog;
    private BottomSheetBehavior bottomSheetBehavior;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_bottom_sheet_dialog);
        ButterKnife.bind(this);
        dialog = new BottomSheetDialog(this);
        View view = getLayoutInflater().inflate(R.layout.bottom_sheet, null);
        dialog.setContentView(view);
        LinearLayout llDialog = (LinearLayout) view.findViewById(R.id.ll_dialog);
        bottomSheetBehavior = BottomSheetBehavior.from(llDialog);
        bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
    }

    @OnClick({R.id.btn_show, R.id.btn_hide})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn_show:
                dialog.show();
                break;
            case R.id.btn_hide:
                dialog.cancel();
                break;
            default:
                break;
        }
    }
}
